import {
  getTrade,
  getAddress
} from "api/api"

export default {
  state: {
    trade:{},
    address:[]
  },
  getters: {
    
  },
  mutations: {
    getTrade(state,{tradeData,addressData}){
      state.trade = tradeData
      state.address = addressData
    }
  },
  actions: {
    async getTrade({commit}){
      try{
        const {code:tradeCode,data:tradeData} = await getTrade();
        const {code:addressCode,data:addressData} = await getAddress()
        console.log(tradeCode,tradeData,addressCode,addressData);
        if(tradeCode===200&&addressCode===200)
          commit("getTrade",{tradeData,addressData})

        return {tradeCode,tradeData,addressCode,addressData}
      }catch(err){
        return err
      }
    }
  }
}
